<template>
	<view>
<!--		<view class="px-4">
			<image :src="bgUrl" class="w-full rounded-lg my-4" style="height: 120px;"></image>
			<view class="bg-white mb-4 px-2 py-4 rounded-lg">
				<view class="flex items-center px-2">
					<u-avatar :src="$util.formatImageIdUrl(unionObj.image)" size="54"></u-avatar>
					<view class="pl-3">
						<view class="font-black text-black-32" v-text="unionObj.title"></view>
						<view class="text-gray-99 mt-1" v-text="unionObj.summary"></view>
					</view>
				</view>
				<view class="rounded mt-4 px-3 py-4 text-sm" style="background-color: #f0f7f0;">
					<u-parse :content="unionObj.content" class="text-gray-66"></u-parse>
				</view>
			</view>
			<view class="mb-2 px-2 text-color-theme font-bold">生命科技成员</view>
		</view>-->
    <view class="px-4" v-if="tabList.length > 0">
      <u-tabs :list="tabList" :activeStyle="{color: '#333333',transform: 'scale(1.05)'}"
              :inactiveStyle="{ color: '#999999',transform: 'scale(1)'}"
              itemStyle="width: 25%;height: 44px;align: center;padding-left: 0px; padding-right: 0px;"
              lineWidth="0" @click="(item)=>{
					dictType = item.val
					reloadData()
				}"></u-tabs>
    </view>
		<view class="bg-white px-4 pb-6">
			<my-page ref="mypage" v-model="dataList" @load-data="loadData">
				<template slot="content">
					<view v-for="(item,index) in dataList" :key="index" class="py-4 border-b-ee flex items-center"
						@click="$util.myNavigateTo('/pages_home/lianmeng/company_detail?id=' + item.id)">
						<image :src="$util.formatImageIdUrl(item.logo)" class="w-16 h-16"></image>
						<view class="flex-1 pl-4">
							<view class="text-black-32 font-bold" v-text="item.name"></view>
							<view  class="mt-1_5 text-gray-66 text-sm zx-multi-ellipsis--2" v-text="item.tagList.replace(/\;/g, '')"></view>
						</view>
					</view>
				</template>
			</my-page>
		</view>
	</view>
</template>

<script>
import {mapState} from 'vuex'
	import MyPage from '@/components/my_page.vue'
	import * as unionApi from '@/interface/junchuang/union.js'
  import * as systemApi from '@/interface/common/system.js'

  export default {
    props: {
      codeType: {
        type: String,
        default: ''
      },
    },
		components: {
			MyPage
		},
		data() {
			return {
				unionObj: {
					title: '',
					image: '',
					summary: '',
					content: ''
				},
				dataList: [],
        tabList: [
          {name: '全部', val: ''},
        ],
				data: {pageTotal: 0,type:''},
				bgUrl: this.$config.server_pic_url + 'bg_lianmeng.png',
        dictType: '',
			}
		},
    computed: {
      ...mapState({
        system: state => state.system
      })
    },
		mounted() {

		},
    onReady() {
      const v = this
      let dictType = ''
      switch (v.codeType) {
        case 'qiye': dictType = 'company_business_type_qiye'; break;
        case 'chanye': dictType = 'company_business_type_chanye'; break;
        case 'shenghuo': dictType = 'company_business_type_shenghuo'; break;
        case 'jinrong': dictType = 'company_business_type_jinrong'; break;
      }
      systemApi.getDictList(dictType).then(({ data }) => {
        data.forEach(item=>{
          v.tabList.push({
            name: item.dictLabel,
            val: item.dictValue
          })
        })
      })
    },
		methods: {
			loadData(page, success, error){
				Object.assign(this.data, page, {
					type: this.codeType,
          businessType: this.dictType
				})
				unionApi.getCompanyPageList(this.data).then(res=>{
					this.data.pageTotal = res.data.total || 0
          console.log("this.data.",res)
					success(res)
				}).catch(error)
			},
      reloadData() {
        this.$refs['mypage'].dataReload()
      }
		}
	}
</script>

<style>
page{
  background-color: #f7f7f7;
}

.masonry {
  column-count: 2;
  column-gap: 0.5rem;
}

.item {
  break-inside: avoid;
  box-sizing: border-box;
}
</style>
